package cn.tedu.exam1.plan.controller;

import cn.tedu.exam1.base.response.JsonResult;
import cn.tedu.exam1.plan.pojo.dto.PlanQuery;
import cn.tedu.exam1.plan.pojo.dto.PlanSavaParam;
import cn.tedu.exam1.plan.pojo.vo.PlanVO;
import cn.tedu.exam1.plan.service.PlanService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/plan/")
public class PlanController {
    @Autowired
    PlanService planService;


    @PostMapping("addPlan")
    public JsonResult addPlan(PlanSavaParam planSavaParam){
        log.debug("新增计划:planSavaParam" + planSavaParam);
        planService.addPlan(planSavaParam);
        return JsonResult.ok();
    }

    @GetMapping("select")
    public JsonResult selectByUserId(PlanQuery planQuery){
        log.debug("查询:planQuery"+planQuery);
        List<PlanVO> list = planService.selectById(planQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("update")
    public JsonResult update(PlanSavaParam planSavaParam){
        log.debug("修改数据:planSavaParam"+planSavaParam);
        planService.update(planSavaParam);
        return JsonResult.ok();
    }

    @GetMapping("delete/{id}")
    public JsonResult deleteById(@PathVariable Long id){
        log.debug("删除:planQuery"+id);
        planService.delete(id);
        return JsonResult.ok();
    }

    @PostMapping("updateStatus/{userId}")
    public JsonResult updateStatus(@PathVariable Long userId){
        log.debug("更新状态:userId"+userId);
        planService.updateStatus(userId);
        return JsonResult.ok();
    }

//    @GetMapping("getDate")
//    public JsonResult getDate(ExamQuery examQuery){
//        log.debug("查询考试时间:examQuery" + examQuery);
//        PlanVO planVO = planService.selectByExam(examQuery);
//        return JsonResult.ok(planVO);
//    }

}
